#
import base64, hmac


#
def token_certify(key, state):
	""" """
	
	# stae
	receive_token = base64.urlsafe_b64decode(state).decode('utf-8')
	receive_token_list = receive_token.split(':')
	
	# token
	receive_token_expire = receive_token_list[0]
	receive_token_sh1 = receive_token_list[1]
	
	print("receive_token_sh1:", receive_token_sh1)
	# database
	key_sh1 = hmac.new(key.encode('utf-8'), receive_token_expire.encode('utf-8'), 'sha1').hexdigest()
	
	print('key_sh1:', key_sh1)
	if key_sh1 == receive_token_sh1:
		return True
	
	return False
	
	
	
	